package com.itcast.interfacedemo.Demo02;

import com.itcast.abstractdemo.Demo01.A;

import java.util.ArrayList;

/*
要写注释哦!!!
*/
public class StudentInterImpl1 implements StudentInter {


    /**
     * 打印出所有学生的信息
     */
    @Override
    public void printAllInfo(ArrayList<Student> students) {
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            System.out.println("=====" + "学生" + (i + 1) + "=====");
            System.out.println("姓名：" + student.getName());
            System.out.println("性别：" + student.getSex());
            System.out.println("成绩：" + student.getScore());
        }
    }

    /**
     * 打印平均成绩
     * @param students
     */
    @Override
    public void printAveragerScore(ArrayList<Student> students) {
        //用来统计所有学生成绩的总和
        double sum = 0;
        double Average = 0;
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            sum += student.getScore();
        }
        Average = sum / students.size();
        System.out.println("所有学生的平均成绩为：" + Average);
    }
}
